package cn.zwx.member.svc.domain.warp;

import cn.zwx.member.svc.domain.bo.CheckUserAddressExistBO;
import cn.zwx.member.svc.domain.entity.AddressEntity;
import cn.zwx.member.svc.domain.enums.AddressTyepEnum;
import cn.zwx.member.svc.rpc.dto.InsertAddressDTO;
import cn.zwx.member.svc.rpc.vo.AddressVO;
import org.springframework.beans.BeanUtils;

/**
 * @author zhangwenxue
 */
public class AddressWrap {

    public static CheckUserAddressExistBO wrap(InsertAddressDTO dto){
        final CheckUserAddressExistBO checkUserAddressExistBO = new CheckUserAddressExistBO();
        BeanUtils.copyProperties(dto,checkUserAddressExistBO);
        return checkUserAddressExistBO;
    }

    public static AddressVO entityToVO(AddressEntity t) {
        final AddressVO addressVO = new AddressVO();
        BeanUtils.copyProperties(t,addressVO);
        addressVO.setIsDefault(t.getIsDefault() == AddressTyepEnum.DEFAULT_.getCode()?Boolean.TRUE:Boolean.FALSE);
        return addressVO;
    }
}
